/**
 * @author cookie
 * Definition for a binary tree node.
 * function TreeNode(val) {
 *     this.val = val;
 *     this.left = this.right = null;
 * }
 */
/**
 * @param {TreeNode} root
 * @return {number[]}
 */
let max = 0
var findMode = function(root) {
    if(!root) return null 
    max = Math.max(root.val, max)
    if(root.left) findMode(root.left)
    if(root.right) findMode(root.right)
    return max    
};


const node = {
    val: 11,
    left:{
        val:12,
        left:{
            val:1100
        },
        right: {
            val:13
        }
    },
    right: {
        val:90,
        left: {
            val:23,
            left: {
                val:12
            },
            right: {
                val:80
            }
        },
        right: {
            val:90,
            left: {
                val:30,
                right: {
                    val:190
                }
            },
            right:{
                val:111
            }
        }
    }
}

const result = findMode(node)
console.log(result);